#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int n, m;
ll f[N];
void init_f() {
  f[1] = 1;
  rep(i, 2, n) {
    ll x = MOD / i, y = MOD % i;
    f[i] = (MOD - x * f[y] % MOD) % MOD;
  }
}
ll a[N];
ll sum2[N << 2], sum[N << 2];
void pushup(int p) {
  sum[p] = (sum[p << 1] + sum[p << 1 | 1]) % MOD;
  sum2[p] = (sum2[p << 1] + sum2[p << 1 | 1]) % MOD;
}
void build(int p, int l, int r) {
  if (l == r) {
    sum[p] = a[l] % MOD;
    sum2[p] = a[l] * a[l] % MOD;
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  pushup(p);
}
void update(int x, ll v, int p, int l, int r) {
  if (l == r) {
    sum[p] = v % MOD;
    sum2[p] = v * v % MOD;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    update(x, v, p << 1, l, mid);
  else
    update(x, v, p << 1 | 1, mid + 1, r);
  pushup(p);
}
ll query(int L, int R, int p, int l, int r) {
  if (L <= l && R >= r) return sum[p];
  int mid = (l + r) >> 1;
  ll res = 0;
  if (L <= mid) res += query(L, R, p << 1, l, mid);
  if (R > mid) res += query(L, R, p << 1 | 1, mid + 1, r);
  return res % MOD;
}
ll query2(int L, int R, int p, int l, int r) {
  if (L <= l && R >= r) return sum2[p];
  int mid = (l + r) >> 1;
  ll res = 0;
  if (L <= mid) res += query2(L, R, p << 1, l, mid);
  if (R > mid) res += query2(L, R, p << 1 | 1, mid + 1, r);
  return res % MOD;
}
ll solve(int L, int R) {
  ll x = query(L, R, 1, 1, n);
  ll y = query2(L, R, 1, 1, n);
  ll z = f[R + 1 - L];
  x = x * z % MOD;
  y = y * z % MOD;
  ll res = (y - x * x % MOD + MOD) % MOD;
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  init_f();
  rep(i, 1, n) cin >> a[i];
  build(1, 1, n);
  while (m--) {
    int op, x, y;
    cin >> op >> x >> y;
    if (op == 1)
      update(x, y, 1, 1, n);
    else
      cout << solve(x, y) << endl;
  }
  return 0;
}